package me.luochenyxh.module.login.ui.fragment

import android.os.Bundle
import android.widget.CompoundButton
import com.blankj.utilcode.util.ToastUtils
import me.luochenyxh.base.base.BaseFragment
import me.luochenyxh.module.login.databinding.LoginRegisterFragmentBinding
import me.luochenyxh.module.login.vm.LoginRegisterViewModel

class RegisterFragment: BaseFragment<LoginRegisterViewModel,LoginRegisterFragmentBinding>() {

    override fun initView(savedInstanceState: Bundle?) {
        mDatabind.click =ProxyClick()

    }

    inner class ProxyClick(){
        /**清空*/
        fun clear() {
            mViewModel.username.postValue("")
        }

        /**注册*/
        fun register() {
//            when {
//                mViewModel.username.get().isEmpty() -> showMessage("请填写账号")
//                mViewModel.password.get().isEmpty() -> showMessage("请填写密码")
//                mViewModel.password2.get().isEmpty() -> showMessage("请填写确认密码")
//                mViewModel.password.get().length < 6 -> showMessage("密码最少6位")
//                mViewModel.password.get() != mViewModel.password2.get() -> showMessage("密码不一致")
//                else -> requestLoginRegisterViewModel.registerAndlogin(
//                    mViewModel.username.get(),
//                    mViewModel.password.get()
//                )
//            }
            ToastUtils.showShort("注册")
        }

        var onCheckedChangeListener1 = CompoundButton.OnCheckedChangeListener { _, isChecked ->
            mViewModel.isShowPwd.postValue(isChecked)
        }
        var onCheckedChangeListener2 = CompoundButton.OnCheckedChangeListener { _, isChecked ->
            mViewModel.isShowPwd2.postValue(isChecked)
        }
    }

}